package spm.project.rememberme;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TextView;

public class HighScore extends Activity {
	TextView easy_score, easy_time, normal_score, normal_time, hard_score,
			hard_time;
	TableLayout table;
	Button back ;
	TextView level , tries , time , easy , normal, hard;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.highscore);
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		int height = metrics.heightPixels;
		int width = metrics.widthPixels;
		
		
		level = (TextView) findViewById(R.id.LevelCell);
		tries = (TextView) findViewById(R.id.TryCell);
		time = (TextView) findViewById(R.id.TimeCell);
		easy = (TextView) findViewById(R.id.EasyCell);
		normal = (TextView) findViewById(R.id.NormalCell);
		hard = (TextView) findViewById(R.id.HardCell);
		
		level.setTextSize((3*width)/100);
		tries.setTextSize((3*width)/100);
		time.setTextSize((3*width)/100);
		easy.setTextSize((3*width)/100);
		normal.setTextSize((3*width)/100);
		hard.setTextSize((3*width)/100);

		
		
		table = (TableLayout) findViewById(R.id.tableLayout1);
		RelativeLayout.LayoutParams parTable = new RelativeLayout.LayoutParams((width*90)/100, (height*30)/100);
		parTable.setMargins((15*width)/100, (40*height)/100, (10*width)/100, (65*height)/100);
		
		table.setLayoutParams(parTable);
		back = (Button) findViewById(R.id.backtomenu);
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((width*33)/100, (height*5)/100);
		params.setMargins((width*33)/100, (height*65)/100, 0, 0);
		back.setLayoutParams(params);
		back.setOnClickListener(new View.OnClickListener() {
    		
    		public void onClick(View v) {
    			Intent i = new Intent(HighScore.this,
						MenuGame.class);
			
				startActivity(i);
    			// TODO Auto-generated method stub
    			finish();
    		}
    	});
		SharedPreferences easy_SP = getSharedPreferences("easy",MODE_WORLD_READABLE);
		int get_easy_score = easy_SP.getInt("easy_score", 0);
		String get_easy_time = easy_SP.getString("easy_time", null);
		easy_score = (TextView) findViewById(R.id.easy_score);
		easy_score.setTextSize((3*width)/100);

		easy_time = (TextView) findViewById(R.id.easy_time);
		easy_time.setTextSize((3*width)/100);

		if (get_easy_score == 0) {
			easy_score.setText("N/A");
			easy_time.setText("N/A");
		} else {
			easy_score.setText(String.valueOf(get_easy_score));
			easy_time.setText(get_easy_time);
		}
		SharedPreferences normal_SP = getSharedPreferences("normal",
				MODE_WORLD_READABLE);

		int get_normal_score = normal_SP.getInt("normal_score", 0);
		String get_normal_time = normal_SP.getString("normal_time", null);
		normal_score = (TextView) findViewById(R.id.normal_score);
		normal_score.setTextSize((3*width)/100);

		normal_time = (TextView) findViewById(R.id.normal_time);
		normal_time.setTextSize((3*width)/100);

		if (get_normal_score == 0) {
			normal_score.setText("N/A");
			normal_time.setText("N/A");
		} else {
			normal_score.setText(String.valueOf(get_normal_score));
			normal_time.setText(get_normal_time);
		}
		
		SharedPreferences hard_SP = getSharedPreferences("hard",
				MODE_WORLD_READABLE);
		int get_hard_score = hard_SP.getInt("SCORE", 0);
		String get_hard_time = hard_SP.getString("time", null);
		hard_score = (TextView) findViewById(R.id.hard_score);
		hard_score.setTextSize((3*width)/100);

		hard_time = (TextView) findViewById(R.id.hard_time);
		hard_time.setTextSize((3*width)/100);

		if (get_hard_score == 0) {
			hard_score.setText("N/A");
			hard_time.setText("N/A");
		} else {
			hard_score.setText(String.valueOf(get_hard_score));
			hard_time.setText(get_hard_time);
		}

	}
	

}
